package com.leorui.schoollife.entity

import net.sf.json.JSONArray
import net.sf.json.JSONObject
import java.io.Serializable

class SchoolResponse : Serializable {
    var status: Int? = null
    var msg: String? = null
    var schoolList: List<SchoolEntity?>? = null

    constructor() : this(null, null, null)
    constructor(status: Int?, msg: String?, schoolList: List<SchoolEntity?>?) {
        this.status = status
        this.msg = msg
        this.schoolList = schoolList
    }

    fun toMap(): Map<Any?, Any?> {
        val result = JSONObject()
        result["status"] = status
        result["msg"] = msg
        val list = JSONArray()
        schoolList?.forEach {
            list.add(it?.toMap())
        }
        result["school_list"] = list.toList()
        return result.toMap()
    }
}

class UserSchoolResponse : Serializable {
    var status: Int? = null
    var msg: String? = null
    var school: SchoolEntity? = null

    constructor() : this(null, null, null)
    constructor(status: Int?, msg: String?, school: SchoolEntity?) {
        this.status = status
        this.msg = msg
        this.school = school
    }

    fun toMap(): Map<Any?, Any?> {
        val result = JSONObject()
        result["status"] = status
        result["msg"] = msg
        result["school"] = school?.toMap()
        return result.toMap()
    }
}

class SchoolEntity : Serializable {
    var schoolId: Int? = null
    var schoolName: String? = null
    var schoolWebUrl: String? = null
    var parseType: Int? = null
    fun toJson(): JSONObject {
        val result = JSONObject()
        result["school_id"] = schoolId
        result["school_name"] = schoolName
        result["school_web_url"] = schoolWebUrl
        result["parse_type"] = parseType
        return result
    }

    fun toMap(): Map<Any?, Any?> {
        val result = JSONObject()
        result["school_id"] = schoolId
        result["school_name"] = schoolName
        result["school_web_url"] = schoolWebUrl
        result["parse_type"] = parseType
        return result.toMap()
    }
}